var personalDatas = require('../../personal-data/personal-data.js')
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    user: '../images/2.jpg',
    uesrFont1: '蓝旗旅居',
    uesrFont2: '高级会员',
    uesrFont3: '收货地址',
    assets: [{
        assetsNum: '14079.2',
        assetsP: '总资产'
      },
      {
        assetsNum: '14079.2',
        assetsP: '可提现'
      },
      {
        assetsNum: '14079.2',
        assetsP: '购物金'
      },
    ],
    inviteCodeText: '123456',
    hostUrl: app.globalData.hostUrl,
    fukuanImg1: '../images/shop.png',
    fukuanP1: '待付款',
    fukuanP2: '待发货',
    fukuanP3: '待收货',
    fukuanP4: '待评价',
    fukuanP5: '退换货',
    userImg1: '../images/shop.png',
    userP1: '购物车',
    userP2: '安全设置',
    userP3: '我的足迹',
    userP4: '邀请注册',
    userP5: '我的团队',
    userP6: '旅居基地',
    userP7: '旅游地产',
    userP8: '健康商城',
    lanqiP: '蓝旗头条',
    userP9: '商城订单管理',
    userP10: '旅居卡管理',
    userP11: '预约看房',
    userP12: '报备管理',
    userP13: '奖金明细',
    userP14: '申请提现',
    userP15: '商家入驻',
    userP16: '平台咨询',
    userP17: '充值申请',
    userP18: '关注蓝旗'

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.setData({
      // often: personalDatas.personalList
      is_show: wx.getStorageSync('is_show')
    })

  },

  getUser: function() { //读取会员

    var that = this;
    var userid = wx.getStorageSync('userId');
    wx.request({
      url: app.globalData.apiUrl + 'user/getUser',
      data: {
        // opt: 'getUser',
        userId: userid,
      },
      header: {
        'content-type': 'application/json'
      },
      success: function(res) {
        console.log(res, '用户信息')
        if (res.data.is_login == 1) {
          that.setData({
            user: res.data,
            canIUse: false,
            zongzichan: (res.data.Scores * 1 + res.data.Commission * 1).toFixed(2),
            Scores: res.data.Scores,
            Commission: res.data.Commission,

          })
          console.log(that.data.zongzichan)
          console.log(res.data.Commission)

        } else {
          that.setData({
            canIUse: wx.canIUse('button.open-type.getUserInfo'),
          })
        }
      }

    })
    // console.log(that.data.canIUse)
  },
  // copy
  copyText: function(e) {
    console.log(e);
    wx.setClipboardData({
      data: e.currentTarget.dataset.text,
      success: function(res) {
        wx.getClipboardData({
          success: function(res) {
            wx.showToast({
              title: '复制成功'
            })
          }
        })
      }
    })
  },

  dingdan: function() {
    wx.navigateTo({
      url: 'dingdan/dingdan',
    })
  },
  dingdan1: function() {
    wx.navigateTo({
      url: 'dingdan/dingdan?currentTab=1',
    })
  },
  dingdan2: function() {
    wx.navigateTo({
      url: 'dingdan/dingdan?currentTab=2',
    })
  },
  dingdan3: function() {
    wx.navigateTo({
      url: 'dingdan/dingdan?currentTab=3',
    })
  },
  dingdan4: function() {
    wx.navigateTo({
      url: 'dingdan/dingdan?currentTab=4',
    })
  },
  // daiTap5: function () {
  //   wx.navigateTo({
  //     url: 'dingdan/dingdan',
  //   })
  // },
  bindUser1: function() {
    wx.navigateTo({
      url: 'shop/shop',
    })
  },
  bindUser2: function() {
    wx.navigateTo({
      url: 'security/security',
    })
  },
  bindUser3: function() {
    wx.navigateTo({
      url: 'zuji/zuji',
    })
  },
  bindUser4: function() {
    wx.navigateTo({
      url: 'yaoqing/yaoqing',
    })
  },
  bindUser5: function() {
    wx.navigateTo({
      url: 'teamper/teamper',
    })
  },
  bindUser6: function() {
    wx.navigateTo({
      url: 'jidisc/jidisc?type=hotel',
    })
  },
  bindUser7: function() {
    wx.navigateTo({
      url: 'jidisc/jidisc?type=house',
    })
  },
  bindUser8: function() {
    wx.navigateTo({
      url: 'jidisc/jidisc?type=product',
    })
  },
  bindLanqi: function() {
    wx.navigateTo({
      url: 'jidisc/jidisc?type=news',
    })
  },
  bindUser9: function() {
    wx.navigateTo({
      url: 'dingdan/dingdan',
    })
  },
  bindUser10: function() {
    wx.navigateTo({
      url: 'lvjuka/lvjuka',
    })
  },
  bindUser11: function() {
    wx.navigateTo({
      url: 'yuyue/yuyue',
    })
  },
  bindUser12: function() {
    // console.log(11)
    wx.navigateTo({
      url: '../baobeiils/baobeiils?IsRecord=1',
    })
  },
  bindUser13: function() {
    wx.navigateTo({
      url: 'zhanghu/zhanghu',
    })
  },
  bindUser14: function() {
    wx.navigateTo({
      url: 'coupon/coupon?shouruhe=' + this.data.user.Commission,
    })
  },
  bindUser15: function() {
    wx.navigateTo({
      url: 'shangjia/shangjia',
    })
  },
  bindUser16: function() {
    wx.navigateTo({
      url: 'zixun/zixun',
    })
  },
  bindUser17: function() {
    wx.navigateTo({
      url: 'topup/topup',
    })
  },
  bindUser18: function() {
    wx.navigateTo({
      url: 'focuson/focuson',
    })
  },

  //退出
  login_out: function() {
    wx.clearStorage();
    wx.redirectTo({
      url: '/pages/login/login',
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    if(!wx.getStorageSync('userId')){
      wx.navigateTo({
        url: '../login/login',
      })
      return ;
    }
    this.getUser();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  },
  grrenxinxi: function() {
    wx.navigateTo({
      url: 'gerenxinxi/gerenxinxi',
    })
  },
  shouhuo: function() {
    wx.navigateTo({
      url: 'address/address',
    })
  },
  jifen: function() {
    wx.navigateTo({
      url: 'jifen/jifen',
    })
  }

})